package luogu.bfs;
//P1332 血色先锋队

import java.util.*;

/**
 * @author :chenjie
 * @date :Created 2022/12/24 15:19
 */
public class TheBloodVanguard {
    static class Pall{
        int x;
        int y;
        int l;

        public Pall(int x, int y, int l) {
            this.x = x;
            this.y = y;
            this.l = l;
        }
    }
    static int n,m,a,b;
    static Queue<Pall> queue=new ArrayDeque<>();
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);

        n=sc.nextInt();
        m=sc.nextInt();
        int[][]arr=new int[n+1][m+1];
        for (int i = 0; i <= n; i++) {
            Arrays.fill(arr[i], (int) 1E9);
        }

        a=sc.nextInt();
        b=sc.nextInt();
        List<Integer> list=new ArrayList<>();
        for (int i = 0; i < a+b; i++) {
            if(i<a){
                int x=sc.nextInt();
                int y=sc.nextInt();
                arr[x][y]=0;
                queue.add(new Pall(x,y,0));
                continue;
            }
            bfs(arr);
            int x=sc.nextInt();
            int y=sc.nextInt();
            list.add(arr[x][y]);
        }

//        for (int i = 0; i <=n; i++) {
//            System.out.println(Arrays.toString(arr[i]));
//        }
        for (Integer integer : list) {
            System.out.println(integer);
        }
    }
    public static void bfs(int[][]arr){
        int[]dx={0,0,1,-1};
        int[]dy={1,-1,0,0};
       while (!queue.isEmpty()){
           Pall remove = queue.remove();

           for (int i = 0; i < 4; i++) {
               int a=remove.x+dx[i],b=remove.y+dy[i];
               if(a>=1&&b>=1&&a<=n&&b<=m&&arr[a][b]!=0&&remove.l+1<arr[a][b]){
                   queue.add(new Pall(a,b, remove.l+1));
                   arr[a][b]=remove.l+1;
               }
           }

       }
    }
}
